#! /usr/bin/env python

# Copyright (C) [2024] Xingyun Integrated Circuit Co., Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
# FIT FOR A PARTICULAR PURPOSE.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Project: GreenCode
# Created Date: 2025-09-17 20:11:49
# Author: Shawn Tan
# -----
# Last Modified: 2025-09-25 20:18:46
# Modified By: Shawn Tan
# -----
# May the force be with you.
# -----
# HISTORY:
# Date      	By	Comments
#                define the groups for ISA 
# ----------------------------------------------------------------------

import sys
reload(sys)
sys.setdefaultencoding('utf-8')
class Group(object): 

    '''
      the ISA GROUP base class for 
    '''
    __pool = []

    def __init__(self, _type=None):
        super(Group, self).__init__()
        if _type != None:
            Group.__pool.append(_type)

    def get_group(self, type): 
        groupType = "Group%s"%(type)
        group = None
        for i in Group.__pool:
            if groupType == i.__name__:
               group = i()
               break

        if group == None:
          print "use default Group for Type : %s"%(type)
          group = Group()
        group.__dict__["name"] = type
        return group

class GroupBRU(Group):
    def __init__(self):
        super(GroupBRU, self).__init__(GroupBRU)

class GroupBCU(Group):
    def __init__(self):
        super(GroupBCU, self).__init__(GroupBCU)

class GroupCVT(Group):
    def __init__(self):
        super(GroupCVT, self).__init__(GroupCVT)

class GroupCVT64(Group):
    def __init__(self):
        super(GroupCVT64, self).__init__(GroupCVT64)

class GroupDALU(Group):
    def __init__(self):
        super(GroupDALU, self).__init__(GroupDALU)

class GroupFALU(Group):
    def __init__(self):
        super(GroupFALU, self).__init__(GroupFALU)

class GroupHALU(Group):
    def __init__(self):
        super(GroupHALU, self).__init__(GroupHALU)

class GroupIALU(Group):
    def __init__(self):
        super(GroupIALU, self).__init__(GroupIALU)

class GroupLSU(Group):
    def __init__(self):
        super(GroupLSU, self).__init__(GroupLSU)

class GroupMISC(Group):
    def __init__(self):
        super(GroupMISC, self).__init__(GroupMISC)

class GroupMMA(Group):
    def __init__(self):
        super(GroupMMA, self).__init__(GroupMMA)

class GroupSYNCOP(Group):
    def __init__(self):
        super(GroupSYNCOP, self).__init__(GroupSYNCOP)

class GroupUDP(Group):
    def __init__(self):
        super(GroupUDP, self).__init__(GroupUDP)

class GroupXU(Group):
    def __init__(self):
        super(GroupXU, self).__init__(GroupXU)


if __name__ == "__main__":
    print "it's not a main modules"
else: 
    import inspect 
    import sys

    for name, _class in inspect.getmembers(sys.modules[__name__], inspect.isclass):
      if "Group" in _class.__name__:
        _class()